let { baseUrl } = require('./base.js')
export default class networkModule {
  /**
   * 登录
   * @param {Function} callback 
   */
  static login(params, callback) {
    var task = wx.request({
      /* 接口 */ 
      url: baseUrl + '/Api/login',
      method: 'GET',
      header: {
        'content-type': 'application/json'
      },
      data: {
        code: params.code,
      },
      success(res) {
        //console.log(res)
        wx.showToast({
            title: res.data.msg,
            icon: 'none',
            duration: 2000
          });
        callback(res.data)
      },
      fail(res) {
        //console.log(res)
        wx.showToast({
          title: '服务器请求失败',
          icon: 'none',
          duration: 2000
        });
        callback({ status: 400, msg: '网络错误' }, res);
      }
    })
    return task;
  }
}